﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;
namespace IHISCETeim.BLL
{
    public class OQualityStrategyController
    {
        /// <summary>
        /// 新增对策基本信息
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static int Add(OQualityStrategyInfo obj, List<OQualityStrategyAttachmentInfo> listAtt)
        {
            return OQualityStrategyDAL.Add(obj, listAtt);            
        }

        /// <summary>
        /// 对策明细信息维护
        /// </summary>
        /// <param name="QSType">l 临时对策，y永久对策</param>
        /// <param name="obj"></param>
        /// <param name="listDetail"></param>
        /// <param name="listAtt"></param>
        /// <returns></returns>
        public static int UpdateDuiCe(string QSType, OQualityStrategyInfo obj, List<OQualityStrategyDetailInfo> listDetail, List<OQualityStrategyAttachmentInfo> listAtt)
        {
            return OQualityStrategyDAL.UpdateDuiCe(QSType, obj,listDetail,listAtt);
        }
        /// <summary>
        /// 删除对策信息，将删除所有的包括明细及附件
        /// </summary>
        /// <param name="QSID"></param>
        /// <returns></returns>
        public static bool Delete(int QSID)
        {
            return OQualityStrategyDAL.Delete(QSID);
        }

        public static OQualityStrategyInfo GetByID(int QSID)
        {
            return CBO.FillObject<OQualityStrategyInfo>( OQualityStrategyDAL.GetByID(QSID));
        }

        public static List<OQualityStrategyAttachmentInfo> GetListAttachmentByQSID(int QSID)
        {
            return CBO.FillCollection<OQualityStrategyAttachmentInfo>( OQualityStrategyDAL.GetListAttachmentByQSID(QSID));
        }
        public static List<OQualityStrategyDetailInfo> GetListDetailByQSID(int ID)
        {
            return CBO.FillCollection<OQualityStrategyDetailInfo>( OQualityStrategyDAL.GetListDetailByQSID(ID));
        }
        public static DataTable GetPagination(string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return OQualityStrategyDAL.GetPagination(WhereSql, PageIndex, PageSize, Sort, ref  TotalCount);
        }
        /// <summary>
        /// 修改基本信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="listAtt"></param>
        /// <returns></returns>
        public static bool Update(OQualityStrategyInfo obj, List<OQualityStrategyAttachmentInfo> listAtt)
        {
            return OQualityStrategyDAL.Update(obj, listAtt);
        }
    }
}
